package com.android.bookgarden.ui;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.baselibs.constract.RealtConstract;
import com.android.bookgarden.R;
import com.android.bookgarden.adapter.CollectionRecordsAdapter;
import com.android.bookgarden.base.BaseActivity;
import com.android.bookgarden.bean.RecordsBean;
import com.android.bookgarden.utli.LogUtil;
import com.android.bookgarden.views.LoadingDialog;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Create by zouqh
 * on 2018/12/1
 **/
public class CollectionRecordsActivity extends BaseActivity implements View.OnClickListener,RealtConstract.View {
    @BindView(R.id.close)
    ImageView close;
    @BindView(R.id.title_text)
    TextView titleText;
    @BindView(R.id.ritgh_icon)
    ImageView ritghIcon;
    @BindView(R.id.ritgh_text)
    TextView ritghText;
    @BindView(R.id.ssb)
    TextView ssb;
    @BindView(R.id.allPrice)
    TextView allPrice;
    @BindView(R.id.recycler)
    RecyclerView recycler;

    private List<RecordsBean> list;
    private CollectionRecordsAdapter adapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_collection_records;
    }

    @Override
    protected void initView() {
        titleText.setText("收款记录");
        close.setOnClickListener(this);
        list = new ArrayList<>();
        list.add(new RecordsBean("***的王二", "2018年8月11号", "8827.00"));
        list.add(new RecordsBean("***的王二", "2018年8月11号", "887.00"));
        list.add(new RecordsBean("***的王二", "2018年8月11号", "887.00"));
        list.add(new RecordsBean("***的王二", "2018年8月11号", "8817.00"));
        list.add(new RecordsBean("***的王二", "2018年8月16号", "8687.00"));
        list.add(new RecordsBean("***的王二", "2018年8月16号", "887.00"));
        list.add(new RecordsBean("***的王二", "2018年8月17号", "8827.00"));
        list.add(new RecordsBean("***的王二", "2018年8月17号", "887.00"));
        adapter = new CollectionRecordsAdapter(list, this);
        recycler.setAdapter(adapter);
        recycler.setLayoutManager(new LinearLayoutManager(this));

    }

    @Override
    public void onRequestPermissions(String str, boolean z) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.close:
                finish();
                break;
        }

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @Override
    public void returnData(String data, int urlCode) {
        LogUtil.e("返回数据", data + "");
        if (TextUtils.isEmpty(data)) {
            return;
        }
        LoadingDialog.hideProgress();
        handler.obtainMessage(urlCode, data).sendToTarget();
    }

    @Override
    public void LoadError(String errorMsg, int urlCode) {
        showToast("请求失败");
        LoadingDialog.hideProgress();
    }
}
